package cn.edu.hbvtc.qms.persist.hibernate;

import java.util.List;

import cn.edu.hbvtc.qms.domain.Clazz;
import cn.edu.hbvtc.qms.domain.ClazzArrangement;
import cn.edu.hbvtc.qms.domain.Teacher;
import cn.edu.hbvtc.qms.domain.Term;
import cn.edu.hbvtc.qms.persist.IClazzArrangementDao;

public class HibernateClazzArrangementDao extends HibernateAbstractDao<ClazzArrangement, Integer>
		implements IClazzArrangementDao {

	private static final long serialVersionUID = 1L;

	public HibernateClazzArrangementDao() {
		super(ClazzArrangement.class);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<ClazzArrangement> findClazzArrangementByTerm(Term term, Clazz clazz) {
	 return this.getHibernateTemplate().find("from ClazzArrangement c where c.term.id = ? and c.clazz.id = ?", new Object[]{term.getId(), clazz.getId()});
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<ClazzArrangement> findClazzArrangementOfTeacher(Teacher teacher, Term term) {
		return this.getHibernateTemplate().find("from ClazzArrangement c where c.teacher.id = ? and c.term.id = ?", new Object[]{teacher.getId(), term.getId()});
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<ClazzArrangement> findClazzArrangementOfClazz(Clazz clazz, Term term) {
		return this.getHibernateTemplate().find("from ClazzArrangement c where c.clazz.id = ? and c.term.id = ?", new Object[]{clazz.getId(), term.getId()});
	}
}
